package com.springboot.domain;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.Date;
import java.util.List;

public class SysUser implements UserDetails {

    private Integer id;

    private String username;

    private String password;

    private String realname;

    private Boolean isexpired;

    private Boolean islock;

    private Boolean iscredentials;

    private Boolean isenabled;

    private Date createtime;

    private Date logintime;

    private List<GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return isexpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return islock;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return iscredentials;
    }

    @Override
    public boolean isEnabled() {
        return isenabled;
    }

    public Integer getId() {
        return id;
    }

    public String getRealname() {
        return realname;
    }

    public Boolean getIsexpired() {
        return isexpired;
    }

    public Boolean getIslock() {
        return islock;
    }

    public Boolean getIscredentials() {
        return iscredentials;
    }

    public Boolean getIsenabled() {
        return isenabled;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public Date getLogintime() {
        return logintime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    public void setLogintime(Date logintime) {
        this.logintime = logintime;
    }

    public void setAuthorities(List<GrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void setRealname(String realname) {
        this.realname = realname;
    }

    public void setIsexpired(Boolean isexpired) {
        this.isexpired = isexpired;
    }

    public void setIslock(Boolean islock) {
        this.islock = islock;
    }

    public void setIscredentials(Boolean iscredentials) {
        this.iscredentials = iscredentials;
    }

    public void setIsenabled(Boolean isenabled) {
        this.isenabled = isenabled;
    }


    public SysUser() {
    }

    public SysUser(Integer id, String username, String password,
                   String realname, Boolean isexpired, Boolean islock,
                   Boolean iscredentials, Boolean isenabled, Date createtime,
                   Date logintime, List<GrantedAuthority> authorities) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.realname = realname;
        this.isexpired = isexpired;
        this.islock = islock;
        this.iscredentials = iscredentials;
        this.isenabled = isenabled;
        this.createtime = createtime;
        this.logintime = logintime;
        this.authorities = authorities;
    }

    @Override
    public String toString() {
        return "SysUser{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", realname='" + realname + '\'' +
                ", isexpired=" + isexpired +
                ", islock=" + islock +
                ", iscredentials=" + iscredentials +
                ", isenabled=" + isenabled +
                ", createtime=" + createtime +
                ", logintime=" + logintime +
                ", authorities=" + authorities +
                '}';
    }
}